package com;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.util.AuthenticateHttpServlet;
import com.util.AuthenticateSession;
@WebServlet("/index")
public class IndexPage extends AuthenticateHttpServlet {

	private static final long serialVersionUID = 1L;

	@Override
	protected void post(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		AuthenticateSession session = (AuthenticateSession)request.getSession().getAttribute("authenticateSession");
		if (session != null) {
			request.setAttribute("username", session.getUsername());
			request.getRequestDispatcher("/WEB-INF/jsp/index.jsp").forward(request,
					response);
		}
		else {
			request.getRequestDispatcher("/login.jsp").forward(request,
					response);
			
		}
	}

}
